package com.newer.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.newer.domain.Inventory;
import com.newer.dto.SupplierDto;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface InventoryMapper extends BaseMapper<Inventory> {


    @Select("select i.* ,t.materialName,t.price,t.unit,c.categoryName from t_material t  inner join t_inventory i on t.materialId =i.materialId inner join t_material_category c on t.categoryId =c.categoryId  where materialName like CONCAT('%',#{uname},'%')")
    @Results({
            @Result(column = "materialName",property = "material.materialname"),
            @Result(column = "price",property = "material.price"),
            @Result(column = "unit",property = "material.unit"),
            @Result(column = "categoryName",property = "materialCategory.categoryname"),

    }
    )
    Page<Inventory> selectAllInventory(Page page, String uname);
}